temp-bikes/01 Agents/01-debug-linear-regression.R

library(parallel)
library(data.table)
library(ggplot2)

############################################################
### Debugging and exploring the linear regression model  ###
############################################################

# Does separate runs produce differing predictions?
regtest <- mclapply(
    rep(1, 4),
    bikes_regression,
    agc = list(1, 600, FALSE),
    mc.cores = 4
)

all_regs  <- rbindlist(regtest, idcol = "run")
head(all_regs)
saveRDS(all_regs, "temp-bikes/agents/all_regs.Rds")

# In case something goes horribly wrong
all_regs$run <- as.factor(all_regs$run)
all_regs[all_regs$t == 667, "lpdens"] <- 0
ggplot(all_regs, aes(x = t, y = lpdens, col = run)) + 
    geom_line() + 
    labs(title = "Lpdens of multiple runs of Bayesian linear regression")
ggsave("temp-bikes/agents/compare_linreg.pdf")
ooelrich/oscbvar documentation built on Sept. 8, 2021, 3:31 p.m.